Advantages & Variations
In this lesson, we'll discuss advantages and variations to the approaches we've already discussed in this chapter.
We'll cover the following
Advantages#
Decoupling via events was presented in the lesson on Events. Such an architecture achieves a high degree of decoupling.
Especially for distributed systems, asynchronous communication has a number of decisive advantages:
-
When a communication partner fails, the message is sent later when the communication partner is available again. In this manner, asynchronous communication offers resilience, that is, protection against the failure of parts of the system.
-
The processing and delivery of a message can nearly always be guaranteed. The messages are stored for a long time. Processing is assured, for example, by the recipients acknowledging the message.
In this manner, asynchronous communication solves challenges caused by distributed systems.
Variations#
Let’s discuss some variations you could apply to the techniques already discussed in this chapter.
The following two chapters introduce concrete technologies for implementing asynchronous communication.
-
Chapter 7 shows Apache Kafka as an example for a message-oriented middleware (MOM). Kafka offers the option to store messages for a very long time. This can be helpful for event sourcing. This feature distinguishes Kafka from other MOMs which are also good options for microservices.
-
Chapter 8 demonstrates the implementation of asynchronous communication with REST and the Atom data format. This can be helpful when MOMs are too much of an effort as additional infrastructure.
-
Asynchronous communication is easy to combine with frontend integration (see chapter 3) because these integrations focus on different levels: frontend and logic.
- However, inconsistencies easily occur during UI integration when two microservices simultaneously present their state on one web page. When the microservices implement things of different domains, they use different data and therefore are rarely inconsistent.
-
However, a combination of asynchronous and synchronous communication (see section 9) should be avoided because synchronous and asynchronous communication both start at the logic level.
- However, even this combination might be sensible in special scenarios. For example, synchronous communication can be necessary if a response of a microservice is required immediately.
Q U I Z
Which of the following is NOT an advantage of asynchronous communication?
A)
Consistency
B)
Guaranteed Delivery
C)
Resilience
We’ll look at a conclusion to this chapter in the next lesson.